< previous page page_339 next page >

Page 339
The Err Object
Visual Basic creates an object that contains error information every time a runtime error is generated. This Err object can be used to retrieve information about the type of error that has occurred. The Err object contains the properties shown in Table 17.1.
Table 17.1 Properties of the Err Object.
PropertyDescription
NumberReturns or sets the current error number. After an error is generated, this property contains a unique error number.
DescriptionReturns or sets the description for the error number generated. The description corresponds to the value in the Number property.
HelpContextContains the Visual Basic Help file context ID for the value in the Number property.
HelpFileContains the path and filename of the Visual Basic Help file. You may also place your own Help filename in this property.
LastDLLErrorThis property contains the error code generated from the last call to a DLL.
SourceThe name of the current Visual Basic project or DLL.

The Err object also has two methods that can be invoked, as listed in Table 17.2.
Table 17.2 Methods of the Err Object.
MethodDescription
ClearClears any information currently contained in the Error object.
RaiseRaises an error, thus triggering an error to occur in the calling program. You must pass at least the Number property as an argument to the Raise method. Also, be sure to clear the object prior to invoking the Raise method.

In the rest of this chapter, youll learn how to use this Err object.

 
< previous page page_339 next page >

If you like this book, buy it!